//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-05-03  Jed Young  Creation
//

using fwt
using gfx
using gfx2
using gfx2Imp

using chunmapDesktop
using chunmapModel
using chunmapUtil
using chunmapView
using chunmapRaster

class Main
{
  Void main()
  {
    map := MapCanvas
    {
      layer0 := VectorLayer.makeUri((this.typeof->sourceFile.toStr.toUri + `data/cntry02/cntry02.shp`))
      layers.add(layer0)

      blLayer := Graticules.createGrid
      layers.add(blLayer)

      fullView
    }

    Bool mocator := false

    Window
    {
      title = "chunmap"
      size = Size(900,600)
      EdgePane
      {
        center = InsetPane { size = Size(900,500); content = map }
        bottom = Button{ text = "reset"; onAction.add { map.fullView.renderMap }}
        top = Button{ text = "reprojection"; onAction.add
        {
          if (!mocator)
          {
            cr := CoordRef{ srid = 1234; name="temp"; projection = Mercator{ name ="mercator" }}
            Reprojection.changeMapCrs(map.layers, cr)
            map.fullView.renderMap
            mocator = true
          }
          else
          {
            Reprojection.changeMapCrs(map.layers, CoordRef.defVal)
            map.fullView.renderMap
            mocator = false
          }
        }}
      },
    }.open
  }
}